home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: Parent Power / The Sunday Times - Parent Power.iso / pc / engine / engine.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2005-11-03  |  14.2 KB  |  524 lines

  1. function init_movie()
  2. {
  3.    _g = _global;
  4.    _g.cdYearFull = 2005;
  5.    _g.shortlistObj = new Object();
  6.    _g.gClipLevel = 500;
  7.    _g.gCriteria_xml = new XML();
  8.    _g.gHelp = new Array();
  9.    _g.gCriteria_list = new Array();
  10.    _g.gSearch_Results_Criteria_list = new Array("distance","name","school_type","school_subtype","st_ranking" + String(_g.cdYearFull).substring(2,4),"st_ranking" + String(_g.cdYearFull - 1).substring(2,4),"town","entry_gender","posx","posy","unique_id");
  11.    _g.gNavActive = "home";
  12.    _g.gGlobalSearch = false;
  13.    var _loc2_ = new Object();
  14.    _loc2_.name = "shortlist";
  15.    _g.gShortlist = data_load(_loc2_);
  16.    if(_g.gShortlist == undefined)
  17.    {
  18.       _loc2_ = new Object();
  19.       _loc2_.name = "shortlist";
  20.       _loc2_.schools = new Array();
  21.       data_save(_loc2_);
  22.       _g.gShortlist = data_load(_loc2_);
  23.    }
  24.    var _loc1_ = new Object();
  25.    _loc1_.name = "pingData";
  26.    _g.gPingData = so_load(_loc1_);
  27.    if(_g.gPingData == undefined)
  28.    {
  29.       _loc1_ = createUserID();
  30.       _loc1_.name = "pingData";
  31.       so_save(_loc1_);
  32.    }
  33.    else
  34.    {
  35.       _loc1_ = _g.gPingData;
  36.       _loc1_.time = getTimeStamp();
  37.       _loc1_.firstTimeIssueRun = false;
  38.       so_save(_loc1_);
  39.    }
  40.    var _loc3_ = "cd=" + _loc1_.cd + "&u=" + _loc1_.userID + "&t=" + _loc1_.time + "&firstTime=" + _loc1_.firstTimeIssueRun;
  41.    sendPingData(_loc3_);
  42.    pingInterval = setInterval(sendPingData,60000,_loc3_);
  43.    getUrl("lingo:Flsh_getPlatform", "");
  44.    _g.ebterms = false;
  45.    _g.hcterms = false;
  46. }
  47. function sendPingData(str)
  48. {
  49.    getURL("lingo:Flsh_sendPing(\"" + str + "\")","");
  50. }
  51. function clearPingData()
  52. {
  53.    clearInterval(pingInterval);
  54. }
  55. function setPlatform(str)
  56. {
  57.    _g.platform = str;
  58. }
  59. function enableFooter()
  60. {
  61.    header.mcDisabler._visible = false;
  62.    header.exit_btn.gotoAndStop("off");
  63. }
  64. function xml_load(xmlDoc)
  65. {
  66.    _g.gCriteria_xml.load(xmlDoc);
  67.    _g.gCriteria_xml.onLoad = xml_parse;
  68. }
  69. function xml_parse()
  70. {
  71.    var data = _g.gCriteria_xml;
  72.    data.ignoreWhite = true;
  73.    data.parseXML(data);
  74.    var len = _g.gCriteria_xml.childNodes[0].childNodes.length;
  75.    var _loc1_ = 0;
  76.    while(_loc1_ < len)
  77.    {
  78.       var attribArray = new Array();
  79.       var _loc3_ = _g.gCriteria_xml.childNodes[0].childNodes[_loc1_].attributes.id;
  80.       var fieldsize = _g.gCriteria_xml.childNodes[0].childNodes[_loc1_].attributes.fieldsize;
  81.       var fieldtype = _g.gCriteria_xml.childNodes[0].childNodes[_loc1_].attributes.fieldtype;
  82.       attribArray.push(_loc3_,fieldsize,fieldtype);
  83.       if(_loc3_ != "")
  84.       {
  85.          _g.gCriteria_list.push(attribArray);
  86.       }
  87.       _loc1_ = _loc1_ + 1;
  88.    }
  89.    var len = _g.gCriteria_xml.childNodes[1].childNodes.length;
  90.    _loc1_ = 0;
  91.    while(_loc1_ < len)
  92.    {
  93.       var _loc2_ = new Object();
  94.       _loc2_.id = _loc1_;
  95.       _loc2_.title = _g.gCriteria_xml.childNodes[1].childNodes[_loc1_].childNodes[0].firstChild.nodeValue;
  96.       _loc2_.content = _g.gCriteria_xml.childNodes[1].childNodes[_loc1_].childNodes[1].firstChild.nodeValue;
  97.       if(_loc3_ != "")
  98.       {
  99.          _g.gHelp.push(_loc2_);
  100.       }
  101.       _loc1_ = _loc1_ + 1;
  102.    }
  103. }
  104. function movie_load(id, clipID, x, y)
  105. {
  106.    if(clipID == undefined)
  107.    {
  108.       if(!content._name)
  109.       {
  110.          createEmptyMovieClip("content",_g.gClipLevel++);
  111.       }
  112.       if(content._url.indexOf(id) == -1)
  113.       {
  114.          if(x || y)
  115.          {
  116.             content._x = x;
  117.             content._y = y;
  118.          }
  119.          content.loadMovie(id);
  120.       }
  121.    }
  122.    else
  123.    {
  124.       createEmptyMovieClip(clipID,_g.gClipLevel++);
  125.       clipID = eval(clipID);
  126.       if(x || y)
  127.       {
  128.          clipID._x = x;
  129.          clipID._y = y;
  130.       }
  131.       clipID.loadMovie(id);
  132.    }
  133.    return true;
  134. }
  135. function data_save(oData)
  136. {
  137.    var _loc1_ = oData;
  138.    trace("* data_save()");
  139.    for(var _loc2_ in _g[_loc1_.name + "Obj"].obj)
  140.    {
  141.       trace("-- " + _loc2_ + ": " + _g[_loc1_.name + "Obj"].obj);
  142.    }
  143.    _g[_loc1_.name + "Obj"].obj = _loc1_;
  144. }
  145. function data_load(oData)
  146. {
  147.    var _loc1_ = oData;
  148.    trace("* data_load()");
  149.    for(var _loc2_ in _g[_loc1_.name + "Obj"].obj)
  150.    {
  151.       trace("-- " + _loc2_ + ": " + _g[_loc1_.name + "Obj"].obj);
  152.    }
  153.    return _g[_loc1_.name + "Obj"].obj;
  154. }
  155. function so_save(oData)
  156. {
  157.    trace("* so_save()");
  158.    var _loc1_ = SharedObject.getLocal(oData.name);
  159.    _loc1_.data.obj = oData;
  160. }
  161. function so_load(oData)
  162. {
  163.    trace("* so_load()");
  164.    var _loc1_ = SharedObject.getLocal(oData.name);
  165.    return _loc1_.data.obj;
  166. }
  167. function shortlist_school(school_id, id)
  168. {
  169.    var i = 0;
  170.    while(i < _g.gShortlist.schools.length)
  171.    {
  172.       if(_g.gShortlist.schools[i].length < 1)
  173.       {
  174.          _g.gShortlist.schools.splice(i,1);
  175.       }
  176.       i++;
  177.    }
  178.    var shortlist = _g.gShortlist.schools.toString();
  179.    if(_g.gShortlist.schools.toString().indexOf(school_id) >= 0)
  180.    {
  181.       var i = 0;
  182.       while(i < _g.gShortlist.schools.length)
  183.       {
  184.          if(_g.gShortlist.schools[i] == school_id)
  185.          {
  186.             _g.gShortlist.schools.splice(i,1);
  187.          }
  188.          i++;
  189.       }
  190.       eval(id).gotoAndPlay("inactive");
  191.    }
  192.    else
  193.    {
  194.       _g.gShortlist.schools.push(school_id);
  195.       eval(id).gotoAndPlay("active");
  196.    }
  197.    var obj = new Object();
  198.    obj.name = "shortlist";
  199.    obj.schools = _g.gShortlist.schools;
  200.    data_save(obj);
  201. }
  202. function getTimeStamp()
  203. {
  204.    var _loc2_ = function(nm)
  205.    {
  206.       var _loc1_ = nm;
  207.       _loc1_ = _loc1_.toString();
  208.       if(_loc1_.length != 1)
  209.       {
  210.          return _loc1_;
  211.       }
  212.       return "0" + _loc1_;
  213.    };
  214.    var _loc1_ = new Date();
  215.    var _loc3_ = "" + _loc2_(_loc1_.getUTCDate()) + "." + _loc2_(_loc1_.getUTCMonth() + 1) + "." + _loc1_.getUTCFullYear() + "_" + _loc2_(_loc1_.getUTCHours()) + "." + _loc2_(_loc1_.getUTCMinutes()) + "." + _loc2_(_loc1_.getUTCSeconds());
  216.    return _loc3_;
  217. }
  218. function colour_change(id, colorTransform)
  219. {
  220.    id = eval(id);
  221.    var col = new Color(id);
  222.    col.setTransform(colorTransform);
  223. }
  224. function nav_activate(id, clip)
  225. {
  226.    help_remove();
  227.    search_in_progress_remove();
  228.    _g.gNavActive = id;
  229.    var navArray = new Array("home","league_tables","schools_of_year","search","shortlist","links");
  230.    var i = 0;
  231.    while(i < navArray.length)
  232.    {
  233.       if(navArray[i] == id)
  234.       {
  235.          eval("nav." + navArray[i]).gotoAndPlay("down");
  236.       }
  237.       else
  238.       {
  239.          eval("nav." + navArray[i]).gotoAndPlay("up");
  240.       }
  241.       i++;
  242.    }
  243. }
  244. function help_preview_view(id, clip, strInsertPos, xOffset, yOffset, absoluteX, absoluteY)
  245. {
  246.    var _loc1_ = id;
  247.    var _loc2_ = this;
  248.    attachMovie("bubble_help","bubble_help",_g.gClipLevel++);
  249.    if(strInsertPos != null)
  250.    {
  251.       bubble_help.gotoAndStop(strInsertPos);
  252.    }
  253.    _loc2_.loc = new Object();
  254.    _loc2_.loc.x = clip._x;
  255.    _loc2_.loc.y = clip._y;
  256.    if(xOffset != null)
  257.    {
  258.       _loc2_.loc.x += xOffset;
  259.    }
  260.    if(yOffset != null)
  261.    {
  262.       _loc2_.loc.y += yOffset;
  263.    }
  264.    if(absoluteX)
  265.    {
  266.       _loc2_.loc.x = absoluteX;
  267.    }
  268.    if(absoluteY)
  269.    {
  270.       _loc2_.loc.y = absoluteY;
  271.    }
  272.    clip._parent.localToGlobal(loc);
  273.    _loc2_.globalToLocal(loc);
  274.    bubble_help._x = _loc2_.loc.x + clip._width;
  275.    bubble_help._y = _loc2_.loc.y + clip._height;
  276.    bubble_help.title.autoSize = true;
  277.    trace("*******************************");
  278.    for(var _loc3_ in _g.gHelp[_loc1_ - 1])
  279.    {
  280.       trace(_loc3_ + ": " + _g.gHelp[_loc1_ - 1][_loc3_]);
  281.    }
  282.    trace("*******************************");
  283.    if(typeof _loc1_ == "number")
  284.    {
  285.       bubble_help.title.text = _g.gHelp[_loc1_ - 1].title;
  286.    }
  287.    else
  288.    {
  289.       bubble_help.title.text = _loc1_.title;
  290.       bubble_help.more_info.text = _loc1_.more_info;
  291.    }
  292.    var width = bubble_help.title._width <= bubble_help.more_info._width ? bubble_help.more_info._width : bubble_help.title._width;
  293.    bubble_help.bg2._width = width;
  294.    if(strInsertPos == "top-right" || strInsertPos == "bottom-right")
  295.    {
  296.       bubble_help.bg2._x = bubble_help.bg3._x - bubble_help.bg2._width;
  297.       bubble_help.bg1._x = Math.ceil(bubble_help.bg2._x - bubble_help.bg1._width);
  298.       bubble_help.title._x = bubble_help.more_info._x = bubble_help.bg2._x;
  299.    }
  300.    else
  301.    {
  302.       bubble_help.bg3._x = Math.floor(bubble_help.bg2._x + bubble_help.bg2._width);
  303.    }
  304. }
  305. function help_view(id, clip)
  306. {
  307.    var _loc1_ = id;
  308.    trace("* help_view()");
  309.    var _loc3_ = undefined;
  310.    var _loc2_ = undefined;
  311.    var more_text = "";
  312.    bubble_help.removeMovieClip();
  313.    attachMovie("interface_disable","interface_disable",_g.gClipLevel++,{_x:0,_y:140});
  314.    interface_disable.onRollOver = function()
  315.    {
  316.    };
  317.    interface_disable.useHandCursor = false;
  318.    attachMovie("help_box","help_box",_g.gClipLevel++,{_x:161,_y:196});
  319.    help_box.title.autoSize = true;
  320.    help_box.content.autoSize = true;
  321.    help_box.content.multiline = true;
  322.    if(typeof _loc1_ == "number")
  323.    {
  324.       _loc3_ = _g.gHelp[_loc1_ - 1].title;
  325.    }
  326.    else
  327.    {
  328.       _loc3_ = _loc1_.title;
  329.    }
  330.    if(typeof _loc1_ == "number")
  331.    {
  332.       _loc2_ = _g.gHelp[_loc1_ - 1].content;
  333.    }
  334.    else
  335.    {
  336.       _loc2_ = _loc1_.content;
  337.    }
  338.    if(_loc1_.more_info)
  339.    {
  340.       more_text = _loc1_.more_info;
  341.    }
  342.    trace("title_text : " + _loc3_);
  343.    trace("body_text : " + _loc2_);
  344.    help_box.title.text = _loc3_;
  345.    help_box.content.htmlText = _loc2_;
  346.    help_box.more_info = more_text;
  347.    help_box.bg2._height = help_box.content._height + (help_box.content._y - help_box.bg2._y) + 45;
  348.    help_box.bg3._y = help_box.bg2._y + help_box.bg2._height;
  349.    help_box.b_close._y = help_box.bg3._y - 30;
  350. }
  351. function help_preview_remove()
  352. {
  353.    bubble_help.removeMovieClip();
  354. }
  355. function help_remove()
  356. {
  357.    interface_disable.removeMovieClip();
  358.    help_box.removeMovieClip();
  359.    bubble_help.removeMovieClip();
  360. }
  361. function dialogue_add(title, txt, y)
  362. {
  363.    var _loc1_ = y;
  364.    trace("dialogue_add:" + title + txt + _loc1_);
  365.    attachMovie("interface_disable","interface_disable",_g.gClipLevel++,{_x:0,_y:140});
  366.    interface_disable.onRollOver = function()
  367.    {
  368.    };
  369.    interface_disable.useHandCursor = false;
  370.    if(!_loc1_)
  371.    {
  372.       _loc1_ = 196;
  373.    }
  374.    attachMovie("help_box","dialogue_box",_g.gClipLevel++,{_x:161,_y:_loc1_});
  375.    dialogue_box.title.autoSize = true;
  376.    dialogue_box.title.text = title;
  377.    dialogue_box.content.autoSize = true;
  378.    dialogue_box.content.htmlText = txt;
  379.    dialogue_box.bg2._height = dialogue_box.content._height + (dialogue_box.content._y - dialogue_box.bg2._y) + 45;
  380.    dialogue_box.bg3._y = dialogue_box.bg2._y + dialogue_box.bg2._height;
  381.    dialogue_box.b_close._y = dialogue_box.bg3._y - 30;
  382.    dialogue_box.b_close.onRelease = function()
  383.    {
  384.       dialogue_remove();
  385.    };
  386. }
  387. function dialogue_remove()
  388. {
  389.    trace("* dialogue_remove()");
  390.    interface_disable.removeMovieClip();
  391.    dialogue_box.removeMovieClip();
  392. }
  393. function show_report_panel(o)
  394. {
  395.    attachMovie("interface_disable","interface_disable",_g.gClipLevel++,{_x:0,_y:140});
  396.    interface_disable.onRollOver = function()
  397.    {
  398.    };
  399.    interface_disable.useHandCursor = false;
  400.    attachMovie("report_clp","report_clp",_g.gClipLevel++,{_x:161,_y:196,oInit:o});
  401. }
  402. function remove_report_panel()
  403. {
  404.    interface_disable.removeMovieClip();
  405.    report_clp.removeMovieClip();
  406. }
  407. function search_in_progress_view()
  408. {
  409.    content.enabled = false;
  410.    help_preview_remove();
  411.    interface_disable.removeMovieClip();
  412.    updateAfterEvent();
  413.    attachMovie("interface_disable","interface_disable",_g.gClipLevel++,{_x:0,_y:140});
  414.    attachMovie("search_in_progress","search_in_progress",500000,{_x:261,_y:276});
  415.    interface_disable.onRollOver = function()
  416.    {
  417.    };
  418.    interface_disable.useHandCursor = false;
  419.    updateAfterEvent();
  420. }
  421. function search_in_progress_remove()
  422. {
  423.    interface_disable.removeMovieClip();
  424.    search_in_progress.removeMovieClip();
  425.    updateAfterEvent();
  426. }
  427. function schools_search_from_feature(search)
  428. {
  429.    content.school_info.removeMovieClip();
  430.    content.search.removeMovieClip();
  431.    content.gotoAndPlay(1);
  432.    content.removeMovieClip();
  433.    searchMovieFunction = "search";
  434.    content.school_info.removeMovieClip();
  435.    nav_activate("search");
  436.    _g.gGlobalSearch = search;
  437.    movie_load("search.swf");
  438. }
  439. XML.prototype.ignoreWhite = true;
  440. XMLnode.prototype.byName = function(name)
  441. {
  442.    var _loc3_ = this.childNodes.length;
  443.    var _loc1_ = 0;
  444.    while(_loc1_ < _loc3_)
  445.    {
  446.       var _loc2_ = this.childNodes[_loc1_];
  447.       if(_loc2_.nodeName == name)
  448.       {
  449.          return _loc2_;
  450.       }
  451.       _loc1_ = _loc1_ + 1;
  452.    }
  453.    return null;
  454. };
  455. XMLnode.prototype.getText = function()
  456. {
  457.    return this.firstChild.nodeValue;
  458. };
  459. XMLnode.prototype.byPath = function(path)
  460. {
  461.    var _loc1_ = this;
  462.    var arrPath = path.split("/");
  463.    var len = arrPath.length;
  464.    var _loc3_ = 0;
  465.    while(_loc3_ < len)
  466.    {
  467.       var _loc2_ = arrPath[_loc3_];
  468.       if(_loc2_.charAt(0) == "@")
  469.       {
  470.          _loc1_ = _loc1_.byID(_loc2_.substring(1));
  471.       }
  472.       else if(_loc2_.charAt(0) == "#")
  473.       {
  474.          _loc1_ = _loc1_.byIndex(parseInt(_loc2_.substring(1)));
  475.       }
  476.       else
  477.       {
  478.          _loc1_ = _loc1_.byName(_loc2_);
  479.       }
  480.       if(!_loc1_)
  481.       {
  482.       }
  483.       _loc3_ = _loc3_ + 1;
  484.    }
  485.    return _loc1_;
  486. };
  487. _global.lingo = function(str)
  488. {
  489.    if(CustomActions == null && $version.toString().substring(4,5) == "7" == false)
  490.    {
  491.       getURL("lingo:" + str,"");
  492.    }
  493. };
  494. _global.fileXML = new XML();
  495. fileXML.onLoad = function()
  496. {
  497.    _global.downloads = this.byPath("downloads");
  498. };
  499. fileXML.load("file.xml");
  500. var createUserID = function()
  501. {
  502.    var _loc1_ = new Object();
  503.    var _loc2_ = Math.random().toString().substr(2,7) + "" + Math.random().toString().substr(2,7);
  504.    if(_g.gPingData.data.firstTimeIssueRun == null)
  505.    {
  506.       firstTime = true;
  507.       _loc1_.firstTimeIssueRun = false;
  508.    }
  509.    else
  510.    {
  511.       firstTime = false;
  512.    }
  513.    _loc1_.cd = "20" + String(_g.cdYearFull).substring(2,3);
  514.    _loc1_.userID = _loc2_;
  515.    _loc1_.firstTimeIssueRun = firstTime;
  516.    _loc1_.time = getTimeStamp();
  517.    return _loc1_;
  518. };
  519. init_movie();
  520. xml_load("criteria.xml");
  521. movie_load("header.swf","header");
  522. movie_load("navigation.swf","nav",0,108);
  523. movie_load("home.swf");
  524.